Skip to main content
Version: 2.0

Upload Media For Template

The Upload API allows you to upload media files.

Before You Start

This guide assumes you have read the Before You Start section.

You will need:

  • A file in one of the following formats:
    • pdf
    • jpeg
    • jpg
    • png
  • A User access token

For Media Uploads-

Steps for uploading media:

Step-1:

To start an upload session, send a POST request.

UAT Endpoint- https://apiuat.aclwhatsapp.com/access-api/api/v1/wa/{waba-id}/media/upload

Production Endpoint- https://api.aclwhatsapp.com/access-api/v1/wa/{WABA-Id}/session/uploads?file_length={file_length}&file_type={filetype}' --header 'Content-Type: image/jpeg'
--header 'Authorization: Bearer xxxx'
--data '@filename' https://api.aclwhatsapp.com/access-api/v1/wa/{waba-id}/mediaUpload/"id": "upload:MTphdHRhY2htZW50OjMzM2YzYjk1LTBhMzUtNGUzNC1iODJmLWQyZTlmYjhhMTJjNj9maWxlX3R5cGU9aW1hZ2UlMkZqcGcmZmlsZV9sZW5ndGg9OTk3Mg==?sig=ARZa4U0ctIz_X2hNHtY"

Sample Curl-

curl --location '
https://api.aclwhatsapp.com/access-api/v1/wa/{WABA -Id}/session/uploads?file_length=9972&file_type=image%2Fjpg'
\
--header 'Content-Type: image/jpeg' \
--header 'Authorization: Bearer xxxx' \
--data '@Ye0zxAm6q/download.jpg'

Request Type- POST

Header Values-

NameValue
Content-typeFixed value- application/json'
AuthorizationBearer token

The above request will return an acknowledgement ID, as a response mentioned below:

{
"acknowledgementId": "1752915620015378432",
"mediaUrl": "https://download.samplelib.com/mp3/sample-3s.mp3",
"expiryTime": 1707972226000,
"status": "success"
}

Response Details-

  • acknowledgementId - An acknowledgementId.
  • mediaUrl – The web URL provided for uploading the media.
  • expiryTime- The time by which media will be available in Meta Servers- Post that the User have to re-upload the media in order to send them in the message.

Step-2:

Get the mediaId from acknowledgementId.

UAT Endpoint- https://apiuat.aclwhatsapp.com/access-api/api/v1/wa/{waba-id}/media
Production Endpoint- https://api.aclwhatsapp.com/access-api/api/v1/wa/{waba-id}/media

Sample Curl-

curl --location '
https://api.aclwhatsapp.com/access-api/v1/wa/177384039855054/mediaUpload/upload:MTphdHRhY2htZW50OmU4YjY1NTMwLWI4YWItNDE3Mi1hN2MzLTM0MDI4ODc2ZjUwNz9maWxlX3R5cGU9aW1hZ2UlMkZqcGcmZmlsZV9sZW5ndGg9OTk3Mg==?sig=ARbcPCQ0v8Jr19FLI4c'
\
--header 'Content-Type: application/octet-stream' \
--header 'Authorization: Bearer xxxx' \
--data '@7JG0_naZZ/download.jpg'

Request Type- POST

Header Values-

NameValue
Content-typeFixed value- application/json'
AuthorizationBearer token

The above request will return a media ID, as a response mentioned below:

{   
"mediaId": "1186780792327418",
"acknowledgementId": "1752915620015378432",
"mediaUrl": "https://download.samplelib.com/mp3/sample-3s.mp3",
"expiryTime": 1707972226000,
"status": "success"
}

Response Details-

  • mediaId - To be used for sending the Carousel message.
  • acknowledgementId - An acknowledgementId.
  • mediaUrl – The web URL provided for uploading the media.
  • expiryTime- The time by which media will be available in Meta Servers- Post that the User have to re-upload the media in order to send them in the message.

Error and Exceptions-

  1. Upload In Progress- If the Media Upload is still in progress at Meta servers following response will be provided by the request.
{
"acknowledgementId": "1755474606652657662",
"mediaUrl": "https://picsum.photos/id/237/200/301",
"expiryTime": 1708582336000,
"status": "media.generation.in.progress",
"errors": [
{
"desc": "Media upload is in progress"
}
]
}
  1. Media Not Found- In case the Media Expires following response will be provided to the client-
{
"acknowledgementId": "1755473752088383468",
"status": "media.not.found"
}
  1. Media Generation Failed- In case the Media upload is failed at Meta Servers following response will be provided to client
{
"acknowledgementId": "1755477593324261376",
"mediaUrl": "https://picsum.phots/id/237/200/30",
"expiryTime": 1708583048000,
"status": "media.generation.failed",
"errors": [
{
"code": "502",
"desc": "Something went wrong while generating mediaId, please try again"
}
]
}

  1. Media already uploaded- In case the Media is already upload earlier at Meta Servers following response will be provided to client
{
"mediaId": "65402eb9-755d-44ef-a9d4-666e48c60708",
"acknowledgementId": "1788877842411425792",
"error": "duplicate.media.upload.request"
}